package org.pzy.java.jvm;

/**
 * @Author: DRevelation
 * @Date: 2022/9/4 10:32
 *
PS D:\gitee\framework-base\java\target\classes\org\pzy\java\jvm> javap -v .\StringTableTest.class
Classfile /D:/gitee/framework-base/java/target/classes/org/pzy/java/jvm/StringTableTest.class
Last modified 2022-9-4; size 1361 bytes
MD5 checksum fcf15194e89ee79baba92f011f48104b
Compiled from "StringTableTest.java"
public class org.pzy.java.jvm.StringTableTest
minor version: 0
major version: 55
flags: ACC_PUBLIC, ACC_SUPER
Constant pool:
#1 = Methodref          #9.#33         // java/lang/Object."<init>":()V
#2 = String             #34            // a
#3 = String             #35            // b
#4 = String             #36            // ab
#5 = InvokeDynamic      #0:#40         // #0:makeConcatWithConstants:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
#6 = Fieldref           #41.#42        // java/lang/System.out:Ljava/io/PrintStream;
#7 = Methodref          #30.#43        // java/io/PrintStream.println:(Z)V
#8 = Class              #44            // org/pzy/java/jvm/StringTableTest
#9 = Class              #45            // java/lang/Object
#10 = Utf8               <init>
#11 = Utf8               ()V
#12 = Utf8               Code
#13 = Utf8               LineNumberTable
#14 = Utf8               LocalVariableTable
#15 = Utf8               this
#16 = Utf8               Lorg/pzy/java/jvm/StringTableTest;
#17 = Utf8               main
#18 = Utf8               ([Ljava/lang/String;)V
#19 = Utf8               args
#20 = Utf8               [Ljava/lang/String;
#21 = Utf8               s1
#22 = Utf8               Ljava/lang/String;
#23 = Utf8               s2
#24 = Utf8               s3
#25 = Utf8               s4
#26 = Utf8               s5
#27 = Utf8               StackMapTable
#28 = Class              #20            // "[Ljava/lang/String;"
#29 = Class              #46            // java/lang/String
#30 = Class              #47            // java/io/PrintStream
#31 = Utf8               SourceFile
#32 = Utf8               StringTableTest.java
#33 = NameAndType        #10:#11        // "<init>":()V
#34 = Utf8               a
#35 = Utf8               b
#36 = Utf8               ab
#37 = Utf8               BootstrapMethods
#38 = MethodHandle       #6:#48         // invokestatic java/lang/invoke/StringConcatFactory.makeConcatWithConstants:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/l
ang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;
#39 = String             #49            //
#40 = NameAndType        #50:#51        // makeConcatWithConstants:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
#41 = Class              #52            // java/lang/System
#42 = NameAndType        #53:#54        // out:Ljava/io/PrintStream;
#43 = NameAndType        #55:#56        // println:(Z)V
#44 = Utf8               org/pzy/java/jvm/StringTableTest
#45 = Utf8               java/lang/Object
#46 = Utf8               java/lang/String
#47 = Utf8               java/io/PrintStream
#48 = Methodref          #57.#58        // java/lang/invoke/StringConcatFactory.makeConcatWithConstants:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/Me
thodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;
#49 = Utf8
#50 = Utf8               makeConcatWithConstants
#51 = Utf8               (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
#52 = Utf8               java/lang/System
#53 = Utf8               out
#54 = Utf8               Ljava/io/PrintStream;
#55 = Utf8               println
#56 = Utf8               (Z)V
#57 = Class              #59            // java/lang/invoke/StringConcatFactory
#58 = NameAndType        #50:#63        // makeConcatWithConstants:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lan
g/Object;)Ljava/lang/invoke/CallSite;
#59 = Utf8               java/lang/invoke/StringConcatFactory
#60 = Class              #65            // java/lang/invoke/MethodHandles$Lookup
#61 = Utf8               Lookup
#62 = Utf8               InnerClasses
#63 = Utf8               (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/String;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;
#64 = Class              #66            // java/lang/invoke/MethodHandles
#65 = Utf8               java/lang/invoke/MethodHandles$Lookup
#66 = Utf8               java/lang/invoke/MethodHandles
{
public org.pzy.java.jvm.StringTableTest();
descriptor: ()V
flags: ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
0: aload_0
1: invokespecial #1                  // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 7: 0
LocalVariableTable:
Start  Length  Slot  Name   Signature
0       5     0  this   Lorg/pzy/java/jvm/StringTableTest;

public static void main(java.lang.String[]);
descriptor: ([Ljava/lang/String;)V
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=3, locals=6, args_size=1
0: ldc           #2                  // String a
2: astore_1
3: ldc           #3                  // String b
5: astore_2
6: ldc           #4                  // String ab
8: astore_3
9: aload_1
10: aload_2
11: invokedynamic #5,  0              // InvokeDynamic #0:makeConcatWithConstants:(Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
16: astore        4
18: getstatic     #6                  // Field java/lang/System.out:Ljava/io/PrintStream;
21: aload_3
22: aload         4
24: if_acmpne     31
27: iconst_1
28: goto          32
31: iconst_0
32: invokevirtual #7                  // Method java/io/PrintStream.println:(Z)V
35: ldc           #4                  // String ab
37: astore        5
39: getstatic     #6                  // Field java/lang/System.out:Ljava/io/PrintStream;
42: aload_3
43: aload         5
45: if_acmpne     52
48: iconst_1
49: goto          53
52: iconst_0
53: invokevirtual #7                  // Method java/io/PrintStream.println:(Z)V
56: return
LineNumberTable:
line 9: 0
line 10: 3
line 11: 6
line 12: 9
line 13: 18
line 14: 35
line 15: 39
line 16: 56
LocalVariableTable:
Start  Length  Slot  Name   Signature
0      57     0  args   [Ljava/lang/String;
3      54     1    s1   Ljava/lang/String;
6      51     2    s2   Ljava/lang/String;
9      48     3    s3   Ljava/lang/String;
18      39     4    s4   Ljava/lang/String;
39      18     5    s5   Ljava/lang/String;
StackMapTable: number_of_entries = 4
frame_type = 255 full_frame
          offset_delta = 31
                  locals = [ class "[Ljava/lang/String;", class java/lang/String, class java/lang/String, class java/lang/String, class java/lang/String ]
        stack = [ class java/io/PrintStream ]
        offset_delta = 0
        locals = [ class "[Ljava/lang/String;", class java/lang/String, class java/lang/String, class java/lang/String, class java/lang/String, class java/lang/String ]
        stack = [ class java/io/PrintStream, int ]
        }
        SourceFile: "StringTableTest.java"
        InnerClasses:
public static final #61= #60 of #64; //Lookup=class java/lang/invoke/MethodHandles$Lookup of class java/lang/invoke/MethodHandles
        BootstrapMethods:
        0: #38 invokestatic java/lang/invoke/StringConcatFactory.makeConcatWithConstants:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/Str
        ing;[Ljava/lang/Object;)Ljava/lang/invoke/CallSite;
        Method arguments:
        #39

        */
public class StringTableTest {
    public static void main(String[] args) {
        String s1 = "a";
        String s2 = "b";
        String s3 = "ab";
        String s4 = s1 + s2;
        System.out.println(s3 == s4);
        String s5 = "a" + "b";
        System.out.println(s3 == s5);
    }
}
